package com.spooky.sync;

import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.spooky.sync.net.NotePullService;
import com.spooky.sync.note.EditorActivity;
import com.spooky.sync.note.NoteListActivity;
import com.spooky.sync.note.TagHandlerActivity;
import com.spooky.sync.preference.SettingsPreference;

public abstract class BaseMenuActivity extends Activity {
	private static final String TAG = "BaseMenuActivity";

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.main_menu, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle item selection
		switch (item.getItemId()) {
		case R.id.listMenuItem: {
			Log.d(TAG, "menu listMenuItem");
			startActivity(new Intent(this, NoteListActivity.class));
			return true;
		}
		case R.id.editorMenuItem: {
			Log.d(TAG, "menu editorMenuItem");
			startActivity(new Intent(this, EditorActivity.class));
			return true;
		}
		case R.id.preferenceMenuItem: {
			Log.d(TAG, "menu preferenceMenuItem");
			startActivity(new Intent(this, SettingsPreference.class));
			return true;
		}
		case R.id.tagHandleMenuItem: {
			Log.d(TAG, "menu tagHandleMenuItem");
			startActivity(new Intent(this, TagHandlerActivity.class));
			return true;
		}
		case R.id.startPullMenuItem: {
			Log.d(TAG, "menu startPullMenuItem");
			startService(new Intent(this, NotePullService.class));
			return true;
		}
		case R.id.stopPullMenuItem: {
			Log.d(TAG, "menu stopPullMenuItem");
			stopService(new Intent(this, NotePullService.class));
			return true;
		}
		default:
			return super.onOptionsItemSelected(item);
		}
	}
}
